package com.lfs.market.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lfs.market.mapper.SystemRoleMapper;
import com.lfs.market.model.dto.SystemRolePageDto;
import com.lfs.market.model.entity.SystemRole;
import com.lfs.market.service.SystemRoleService;
import org.springframework.stereotype.Service;

@Service
public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemRole> implements SystemRoleService {
    @Override
    public Page getRolePageList(SystemRolePageDto rolePageDto) {
        Page<SystemRole> page = lambdaQuery()
                .like(StrUtil.isNotEmpty(rolePageDto.getKey()), SystemRole::getRoleCode, rolePageDto.getKey()).or()
                .like(StrUtil.isNotEmpty(rolePageDto.getKey()), SystemRole::getRoleName, rolePageDto.getKey())
                .orderByDesc(SystemRole::getCreateTime)
                .page(new Page<>(rolePageDto.getPageNumber(), rolePageDto.getPageSize()));
        return page;
    }
}
